package com.weixin.paleituo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.bean.LevelsBean;
import com.weixin.paleituo.util.UIUtils;
import com.weixin.paleituo.view.MyGridView;

import java.util.List;

/**
 * Author yichao
 * Time  2017/12/1 0:38
 * Dest  售卖内容
 */

public class SaleStatusContentRecyclerViewAdapter extends RecyclerView.Adapter<SaleStatusContentRecyclerViewAdapter.ViewHolder> {


    private Context mContext;
    private List<LevelsBean> mLevels;

    public void setLevels(List<LevelsBean> levels) {
        mLevels = levels;
    }

    public SaleStatusContentRecyclerViewAdapter(Context context, List<LevelsBean> levels) {
        mContext = context;
        mLevels = levels;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= UIUtils.inflate(mContext,R.layout.sale_status_content_item_layout,parent,false);

        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder,final int position) {
      /*  holder.mFlowLayout.removeAllViews();
      for (int i=0;i<20;i++){

          LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(UIUtils.dip2px(40), UIUtils.dip2px(40));

          params.leftMargin = 20;

          TextView textView=new TextView(mContext);
          textView.setText("0101");
          textView.setBackgroundColor(R.color.c_383838);

         textView.setBackgroundColor(Color.parseColor("#7ef7bc"));
          textView.setGravity(Gravity.CENTER);

          holder.mFlowLayout.addView(textView,params);
      }*/
   /*     List<String> strings=new ArrayList<>();
        for (int i=0;i<10;i++){

            strings.add(i+"");
        }*/

        holder.mTextViewTitle.setText(mLevels.get(position).getLevel()+"F");
        SaleHouseStatusGridViewAdapter saleHouseStatusGridViewAdapter=new SaleHouseStatusGridViewAdapter(mContext,mLevels.get(position).getRooms());
        holder.mMyGridView.setAdapter(saleHouseStatusGridViewAdapter);


if (mOnItemClickListener!=null){
    holder.mItemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mOnItemClickListener.onClick(v,position);
        }
    });


}
    }

    @Override
    public int getItemCount() {
        return mLevels.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private View mItemView;
        private MyGridView mMyGridView;
        private TextView mTextViewTitle;

        public ViewHolder(View itemView) {
            super(itemView);
            mItemView = itemView;
          //  mFlowLayout= mItemView.findViewById(R.id.flowlayout_sale_status_menu);
            mMyGridView = mItemView.findViewById(R.id.gridView_sale_status_menu);
            mTextViewTitle=   mItemView.findViewById(R.id.tv_title_sale_statues_content_item_layout);




        }
    }
private OnItemClickListener mOnItemClickListener;
    public interface OnItemClickListener{
      public   void onClick(View v, int position);

    }
public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.mOnItemClickListener=onItemClickListener;

}

}
